<?php  
defined('APPLICATION_URL')||define('APPLICATION_URL', '/ITjap(tung)/ITjap_finalversion');  
session_start();
$userId=$_SESSION['userId'];
if(!isset($userId)) header('Location:'.APPLICATION_URL.'/index.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- head - Finished -->
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
	<link rel="stylesheet" href="<?php echo APPLICATION_URL;?>/css/layout.css" type="text/css" media="screen" />
	<link rel="stylesheet" href="<?php echo APPLICATION_URL;?>/css/home.css" type="text/css" media="screen" />
	<link rel="stylesheet" href="<?php echo APPLICATION_URL;?>/css/sys.css" type="text/css" media="screen" />	
	<title>会議室予約システム</title>
</head>
<!-- /head - Finished -->

<body>
<!-- header area -->
	<div id="header_area">
	  <div id="header">
	    <div id="header_link_area">
	      <a name="pagetop"></a>
	      <div id="header_appeal">会議室予約システム</div>
	      <div id="header_link">
	        <ul>
	          <li class="header_b_1"><a href="<?php echo APPLICATION_URL;?>/view/user/view_room.php" class="header_b_1"><img src="<?php echo APPLICATION_URL;?>/images/header/header_b_1.gif" alt="ホーム" width="56" height="21" /></a></li>
	          <li class="logout"><a href="<?php echo APPLICATION_URL;?>/controller/logout.php" class="header_b_2"><img src="<?php echo APPLICATION_URL;?>/images/header/header_b_5.gif" alt="会社概要" width="71" height="21" /></a></li>
	          <li class="header_b_3"><a href="<?php echo APPLICATION_URL;?>/view/user/Register.php" class="header_b_3"><img src="<?php echo APPLICATION_URL;?>/images/header/header_b_3.gif" alt="特定商取引に基づく表記" width="155" height="21" /></a></li>
	          <li class="header_b_4"><a href="<?php echo APPLICATION_URL;?>/index.php" class="header_b_4"><img src="<?php echo APPLICATION_URL;?>/images/header/header_b_4.gif" alt="お問い合せ" width="82" height="21" /></a></li>
	        </ul>
	      </div>
	    </div>
	    <div id="header_title">
	       <img id="SiteHeader1_imgTitle" src="<?php echo APPLICATION_URL;?>/images/header/header_title_1.gif" alt="貸会議室予約" style="height:90px;width:960px;border-width:0px;" /> 
	    </div>
	  </div>
	</div>
<!-- header area-->
	
<!-- pan_area -->
	      <div id="pan_area">
	        <div id="pan">
	          <ul>
	            <li><a href="<?php echo APPLICATION_URL;?>/view/user/view_room.php">ホーム</a></li>
	          </ul>
	        </div>
	      </div>
<!-- pan_area -->
	  
<!-- main_area -->
	<div id="main_top_area">&nbsp;</div>
	    
	<!-- main_middle_area -->   
	<div id="main_middle_area">
	
	    <!-- main area-->
		<div id="main_area">
		
			<!-- main -->
			<div id="main">
				  <!-- navi -->
				      <div id="navi">
				        <ul>
				          <li class="tenanto_yoyaku"><a href="<?php echo APPLICATION_URL;?>/view/user/book_room.php" class="navi_b_1"><img src="<?php echo APPLICATION_URL;?>/images/navi/tenanto_yoyaku.gif" alt="会議室予約" width="145" height="39" /></a></li>
				          <li class="tenanto_sansho"><a href="<?php echo APPLICATION_URL;?>/view/user/view_room.php" class="navi_b_2"><img src="<?php echo APPLICATION_URL;?>/images/navi/tenanto_sansho.gif" alt="予約参照" width="145" height="39" /></a></li>
				          <li class="tenanto_setting"><a href="<?php echo APPLICATION_URL;?>/view/user/Change_Info.php" class="navi_b_3"><img src="<?php echo APPLICATION_URL;?>/images/navi/tenanto_setting.gif" alt="個人情報変更" width="145" height="39" /></a></li>
				          <li class="tenanto_resetpass"><a href="<?php echo APPLICATION_URL;?>/view/user/Change_pass.php" class="navi_b_4"><img src="<?php echo APPLICATION_URL;?>/images/navi/tenanto_resetpass.gif" alt="パスワード変更" width="145" height="39" /></a></li>
					    </ul>
				      </div>
				   <!-- /navi -->
				   <!-- contents -->
				       <div id="content">
				       		  <h1><img src="<?php echo APPLICATION_URL;?>/images/h1_faq.gif" alt="よくあるご質問" /></h1>
				       		  <!-- result -->
              <div id="pnlResult" class="result">             
                <p class="result">会議室<span id="lblRoomName">「会議室」</span>の空室状況</p>                                                               
                <!-- schedule -->
                <p class="title">今月の予約候補とする会議室の［会議室の参照］ボタンをクリックしてください</p>
                <form action="<?php echo APPLICATION_URL;?>/controller/viewOrderedController.php" method="post">      
                 <input type="Submit" value="会議室の参照">
                </form>   
                <p class="title">今月の課金状況の［課金の参照参照］ボタンをクリックしてください</p>
                <form action="<?php echo APPLICATION_URL;?>/controller/getUserFee.php" method="post">      
                 <input type="Submit" value="課金の参照">
                </form>
                <?php 
                if($output=='none')
                {
                	echo "<script type='text/javascript'>\n";
					echo "alert('no order in this month');\n";
					echo "</script>";
                }
                elseif($output!=null)
                {
                	//var_dump($output);die;
                	print "<form action=\"".APPLICATION_URL."/controller/cancelOrder.php\" method=\"post\">";
                    print "<table class=\"result\">";
                    print "<tr>";
                    print "<th class=\"result_th_1\">利用日</th>";
                    print "<th>空室</th>";
                    print "<th>予約時間</th>";
                    print "<th>状態</th>";
                    print "</tr>";
                    foreach($output as $date)
                    {
                    	$roomName=$date['roomName'];
                    	$pos = strpos($date['time'] , "->");
						$orderStartTime = substr($date['time'], 0, $pos);
						$orderEndTime = substr($date['time'], $pos+2);
						$startTime=date('H:i:s',strtotime($orderStartTime));
						$endTime=date('H:i:s',strtotime($orderEndTime));
						$day=date('Y-m-d',strtotime($orderStartTime));
						$viewTime=$startTime.'->'.$endTime;
						$flag=$date['flag'];
						print "<tr>";
						print "<td>$day</td>";
						print "<td>$roomName</td>";
						print "<td>$viewTime</td>";
						if($flag==0)
						{
							print "<td>キャンセルできる";
							$orderId=$date['orderId'];
							print "<input type=\"checkbox\" value=\"$orderId\" name=\"orderId[]\">";
							print "</td>";
						}
						else if($flag==1)
							print "<td>キャンセルしました</td>";
						else print "<td>使えました</td>";
						print "</tr>";
						
                    }
                    print  "</table>";       
                    print  "<input type=\"Submit\" value=\"キャンセル\">";              
                   	print "</form>";
                } 	
                       // Mảng ngày	
                   /* foreach ($date_list as $date){		
	                       for($i=1;$i<=48;$i++){ 
		                       	if($i==1){
		                       		print "<tr>";
		                       		print "<td rowspan=\"8\">$date</td>";
		                       		if($check[$i]==0)
		                       			print "<td>&nbsp;</td>";
		                       		else
		                       			print "<td>$time[$i]<input type=\"checkbox\" value=\"$date.$i\"></td>";//$date.$i là gia tri gui len server khi an submit
		                       	}
		                       	else if($i==6||$i==12||$i==18||$i==24||$i==30||$i==36||$i==42||$i==42){
		                       		if($check[$i]==0)
		                       			print "<td>&nbsp;</td>";
		                       		else
		                       		print "<td>$time[$i]<input type=\"checkbox\" value=\"$date.$i\"></td>";
		                       		
		                       		print "</tr>";
		                       	}
		                       	else if($i==7||$i==13||$i==19||$i==25||$i==31||$i==37||$i==43){
		                       		print "<tr>";
		                       		if($check[$i]==0)
		                       			print "<td>&nbsp;</td>";
		                       		else 
		                       		print "<td>$time[$i]<input type=\"checkbox\" value=\"$date.$i\"></td>";
		                       	}
		                       	
		                       	else {
		                       		if($check[$i]==0)
		                       			print "<td>&nbsp;</td>";
		                       		else
		                       		print "<td>$time[$i]<input type=\"checkbox\" value=\"$date.$i\"></td>";
		                       	}                   
	                       }
                       }     */                  
                
                ?>                                
				</div>
              <!-- result -->
			  </div>

				    <!-- /contents -->			    
			</div>
	  		<!-- /main -->	  		
		      <div id="pr"><p>&nbsp;</p></div>
			</div>
	    </div>
	     <!-- /main_middle_area -->
	<div id="main_bottom_area">&nbsp;</div>
<!-- main_area -->
      
<!-- FOOTER -->
	<div id="footer_area">
	  <div id="footer">
	    <ul>
	      <li class="left"><a href="<?php echo APPLICATION_URL;?>/index.php">ホーム</a></li>
	      <li><a href="<?php echo APPLICATION_URL;?>/view/user/logout.php">ログアウト</a></li>
	      <li><a href="<?php echo APPLICATION_URL;?>/view/user/register.php">個人情報変更</a></li>
	      <li><a href="<?php echo APPLICATION_URL;?>/index.php">Q&A</a></li>
	    </ul>
	    <p>Copyright&nbsp;&copy;&nbsp;Team 08</p>
	  </div>
	</div>
<!-- FOOTER -->	
</body>
</html>